package com.agent.controller;

import java.util.HashMap;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.agent.tool.AjaxReturnTool;
import com.agent.tool.CommonTool;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;

public class BaseController {
	public AjaxReturnTool ajaxReturnTool = new AjaxReturnTool();
	@Autowired
	public CommonTool coTool;
	public static final Logger logger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
	public Gson gson = new GsonBuilder().serializeNulls().create();
	
	@SuppressWarnings("serial")
	public List<HashMap<String,Object>> toListHashByJsonString(String jsonString){
		return gson.fromJson(jsonString, new TypeToken<List<HashMap<String,Object>>>(){}.getType());
	}
	@SuppressWarnings("serial")
	public HashMap<String,Object> toHashMapByJsonString(String jsonString){
		return gson.fromJson(jsonString, new TypeToken<HashMap<String,Object>>(){}.getType());
	}
}
